<template>
    <div class="common-layout">
        <el-container>
            <!-- 标题 -->
            <el-header>
                xxxx大型后台管理系统
                <div class="user" @mouseenter="enterUser" @mouseleave="leaveUser">
                    <i class="el-icon-user"></i>
                    <el-dropdown @command="logout">
                        <span class="el-dropdown-link">
                            <el-icon>
                                <User />
                            </el-icon>
                            {{ store.getters.getUserInfo.username }}<el-icon v-if="tag" class="el-icon--right"><arrow-down /></el-icon ><el-icon v-else class="el-icon--right"><ArrowUp /></el-icon>
                        </span>
                        <template #dropdown>
                            <el-dropdown-menu>
                                <el-dropdown-item icon="Close" command="1">退出登录</el-dropdown-item>
                            </el-dropdown-menu>
                        </template>
                    </el-dropdown>
                </div>
            </el-header>
            <el-container>
                <!-- 侧边栏 -->
                <v-nav></v-nav>
                <!-- 主体部分 -->
                <el-main>
                    <!-- 二级路由出口 -->
                    <router-view></router-view>
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>
<script setup lang="ts">
import {
    ArrowDown,
    Check,
    CircleCheck,
    CirclePlus,
    CirclePlusFilled,
    Plus,
} from '@element-plus/icons-vue'
// 引入侧边栏组件
import vNav from '../components/vNav.vue'
import { useStore } from 'vuex';
import { ref } from 'vue';
import { ElMessage } from 'element-plus';
import { useRouter } from 'vue-router';
// 调用仓库
let store = useStore();
//调用路由
let router = useRouter();

let tag = ref(false);
66

// 退出登录
const logout = (com: string) => {
    // 接收回调参数  如果com==1 才会执行退出登录
    if (com == '1') {
        ElMessage.success('退出成功')
        // 调用仓库中的CHANGE_USERINFO清除缓存
        store.commit('CHANGE_USERINFO', false);
        // 跳转登录页面
        router.push('/login');
    }

}
// 划入事件  更改tag值
const enterUser = () => {
    tag.value = true;
}
// 滑出事件  更改tag值
const leaveUser = () => {
    tag.value = false;
}
</script>
<style scoped lang="less">
.common-layout {
    height: 100%;
}

.el-header {
    font-size: 25px;
    background-color: pink;
    line-height: 60px;
    text-align: center;

}

.el-container {
    // height: 600px;
    height: 100%;
}

.example-showcase .el-dropdown-link {
    cursor: pointer;
    color: var(--el-color-primary);
    display: flex;
    align-items: center;
}
.user {
    margin-top: 25px;
    font-size: 20px;
    margin-right: 20px;
    float: right;


}
</style>